package com.jsf.service;

import com.jsf.entity.OtherUser;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;

import javax.faces.view.ViewScoped;
import javax.inject.Named;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Admin
 */
@Named
@ViewScoped
public class StatusService implements Serializable{
    
    
    
    private UserService service = new UserService();
    
    private static List<OtherUser> list; 
    
    private String[] name;

    
    
    public UserService getService() {
        UserService service  = new UserService();
        return service;
    }
    
    
    public void setService(UserService service) {
        this.service = service;
    }
    

    /**
     * @return the name
     */
    public String[] getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String[] name) {
        this.name = name;
    }
    
    @PostConstruct
    public void init() {

    }
    
    public List<OtherUser> getUser(){
       list = service.getList();
       return list;
    }
    public void selectUser(){
        for(int i=0;i<list.size();i++) {
            OtherUser user = list.get(i);
            if(user.getStatus()==false){
                list.remove(i);
            }
        }
    }
    
    public void userChange(){
        
        service.changeUser(name);
    }
    
    public void userReturn(){
        service.returnUser(name);
    }
     
}
